<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8" />
		<title></title>
	</head>

	<body>
		<canvas id="canvas" style="border: 1px solid red;"></canvas>
		<script type="text/javascript">
			window.onload = function() {
				var canvas = document.getElementById("canvas")
				var cxt = canvas.getContext("2d")
				canvas.width = 550;
				canvas.height = 400;

				var n = 0
				var settime = window.setInterval(function() {
					//创建img对象
					var img = new Image()
					img.src = "img/18.png"

					//图片对象必须加载后才可以使用
					img.onload = function() {
						cxt.drawImage(img, 0 + 114 * n, 0, 120, 135, 50, 50, 120, 135)
					}
					if(n >= 7) {
						n = 0;
					} else {
						n++;
					}
				},17)

			}
		</script>
	</body>

</html>